<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../jquery-3.1.1.js"></script>
</head>

<body>
    <p>密码等级，至少6位数,至多12位</p>
    <input type="text" name="" id="vall">
    <span></span>
</body>
<script>
    $(function () {
        
        $('input').keyup(function () {
            let inputVal = $('#vall').val();
            if (inputVal.length >= 6 && inputVal.length <= 12) {
                console.log(inputVal.length)
                console.log(inputVal)
                let chuji = /[0-9][^a-zA-Z\S\s]*$/g
                let zhongji = /[a-zA-Z0-9][^\S\s]*$/g
                let gaoji = /[a-zA-Z0-9]\S*$/g
                let cj = chuji.test(inputVal)
                let zj = zhongji.test(inputVal)
                let gj = gaoji.test(inputVal)
                console.log(cj)
                if (cj) {
                    $('span').text('初级')
                } else if(zj){
                    $('span').text('中级')
                } else if(gj){
                    $('span').text('高级')
                }

                

            }else{
                if (inputVal.length > 12) {
                    $('span').text('至多12位')
            }
                

            }
        })


    })
</script>

</html>